package com.lebang.service;

import com.lebang.domain.MemberHeaderHistory;
import com.lebang.entity.RequestHeaders;
import com.lebang.example.MemberHeaderHistoryExample;
import com.lebang.mapper.MemberHeaderHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: xwj
 * @Date: 2020/06/16 13:44
 * @Version 1.0
 */
@Service
public class MemberHeaderHistoryService extends BaseService<MemberHeaderHistory, Integer, MemberHeaderHistoryExample> {

    @Autowired
    private MemberHeaderHistoryMapper memberHeaderHistoryMapper;



    public void insertMemberHeaderInfo(RequestHeaders requestHeaders) {
        MemberHeaderHistory memberHeaderHistory = new MemberHeaderHistory(requestHeaders);
        Integer count = memberHeaderHistoryMapper.countByMemberId(requestHeaders.getUserid());
        if (count==0) {
            memberHeaderHistoryMapper.insertSelective(memberHeaderHistory);
        } else {
            memberHeaderHistoryMapper.updateByMemberId(memberHeaderHistory);
        }

    }

}
